function  loginOut(){
    $.ajax({
        type:"get",
        url:"/sys?fid=2",
        success:function( info ){
            var code = info.code;
            var desc = info.desc;
            if( code == 1 )
            {
                location.href = "login.html";
            }
            else
            {
                if( code == 2 )
                {
                    location.href = "login.html";
                }
                else
                {
                    $("#loginoutModal").modal();
                    $("#tipsContent").html(desc);
                }
            }


        }
    });

}
// 分页
function  getPages(pn,tp, fn){
    var pagehtml = '<a href="javascript:;"  onclick="'+fn+'('+(pn > 1 ? (pn - 1) : 1)+')"   class="prepage">上一页</a>';
    var max = 0,min = 0;
    var  maxshow = 7;//最大显示7页
    if (tp > maxshow)
    {
        if (pn >= 7) 
        {
            if (tp - pn >= 3) 
            {
                min = pn - 3;
                max = pn + 3;
            } 
            else if (tp - pn < 3) 
            {
                min = tp - 6;
                max = tp;
            }

        } 
        else 
        {
            min = 1;
            max = 7;
        }

    }
    else
    {
        min = 1;
        max = tp;
    }
    for (var i = min; i <= max; i++) {
        if (i == pn || (i == 1 && pn == 1)) {
            pagehtml += '<a href="javascript:;" class="active" onclick="'+fn+'('+i+')">'+i+'</a>';

        } else {
            pagehtml += '<a href="javascript:;" onclick="'+fn+'('+i+')">'+i+'</a>';
        }

    }

    if (pn >= tp) {
        pagehtml += '<a href="javascript:;" onclick="'+fn+'('+max+')"  class="nextpage">下一页</a>';
    } else {
         pagehtml += '<a href="javascript:;" onclick="'+fn+'('+(pn+1)+')"   class="nextpage">下一页</a>';
    }

    return pagehtml;
}
Date.prototype.dateadd = function (strInterval, Number) {
    var dtTmp = this;
    switch (strInterval) {
        case 's':
            return new Date(Date.parse(dtTmp) + (1000 * Number));
        case 'n':
            return new Date(Date.parse(dtTmp) + (60000 * Number));
        case 'h':
            return new Date(Date.parse(dtTmp) + (3600000 * Number));
        case 'd':
            return new Date(Date.parse(dtTmp) + (86400000 * Number));
        case 'w':
            return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
        case 'q':
            return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number * 3, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
        case 'm':
            return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
        case 'y':
            return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
    }
};

Date.prototype.format = function (tpl) {
    var strs, w, keys, year, val;
    strs = [];
    tpl = tpl || 'YY\u5e74MM\u6708DD\u65e5 \u661f\u671fdd';
    w = 'FullYear,Month,Date,Hours,Minutes,Seconds,Day'.split(',');
    keys = [/YY/g, /Y/g, /MM/g, /M/g, /DD/g, /D/g, /hh/g, /h/g, /mm/g, /m/g, /ss/g, /s/g, /dd/g, /d/g];
    for (var i = 0; i < 7; i++) {
        val = this['get' + w[i]]() + (w[i] === 'Month' ? 1 : 0);
        strs.push(('0' + val).slice(-2), val);
    }
    year = [strs[1], strs[0]].concat(strs.slice(2, -2));
    year.push('\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d'.substr(strs.slice(-1), 1), strs.slice(-1));
    for (var i = 0; i < 14; i++) {
        tpl = tpl.replace(keys[i], year[i]);
    }
    return tpl;
};

String.prototype.getParam = function (n) {
    var r = new RegExp("[\?\&]" + n + "=([^&?]*)(\\s||$)", "gi");
    var r1 = new RegExp(n + "=", "gi");
    var m = this.match(r);
    if (m == null) {
        return "";
    } else {
        return typeof (m[0].split(r1)[1]) == 'undefined' ? '' : decodeURIComponent(m[0].split(r1)[1]);
    }
};
$.alert=function( code, alerttxt ){
    if( code == 2 )
    {
        location.href = "login.html";
    }
    else
    {
        $("#tipsContent").html( alerttxt );
        $("#loginoutModal").modal();
    }

};


